package com.biwin.common.api.mapper;

import com.biwin.common.api.dto.IBwDto;
import com.biwin.common.api.entity.IBwEntity;
import com.biwin.common.api.vo.IBwVo;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.MappingTarget;

import java.util.List;

/**
 * TODO
 *
 * @author biwin
 * @since
 */
public interface IBwMapper<D extends IBwDto, E extends IBwEntity, V extends IBwVo> {

    /**
     * 将 dto 与 entity 属性拷贝后返回 entity
     * @param dto
     * @param entity
     * @return
     */
    @InheritConfiguration
    E mergeEntity(D dto, @MappingTarget E entity);

    /**
     * 将 dto 转成 entity
     * @param dto
     * @return
     */
    E toEntity(D dto);

    /**
     * 将 entity 转成 vo
     * @param entity
     * @return
     */
//    V toVo(E entity, @Context CycleAvoidingMappingContext context);
    V toVo(E entity);

    /**
     *
     * @param dtoList
     * @return
     */
    List<E> toEntity(List<D> dtoList);

    List<V> toVo(List<E> entityList);
}
